package org.eclipse.pde.toolbox.adaptors.view;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.pde.toolbox.Activator;
import org.eclipse.pde.toolbox.adaptors.internal.AdaptorLeaf;
import org.eclipse.pde.toolbox.adaptors.internal.AdaptorParent;
import org.eclipse.pde.toolbox.adaptors.internal.FactoryLeaf;
import org.eclipse.pde.toolbox.adaptors.internal.FactoryParent;
import org.eclipse.pde.toolbox.adaptors.internal.ITreeNode;
import org.eclipse.pde.toolbox.adaptors.internal.MyContributor;
import org.eclipse.pde.toolbox.adaptors.internal.NamespaceParent;
import org.eclipse.pde.toolbox.adaptors.internal.PluginAdapter;
import org.eclipse.pde.toolbox.adaptors.internal.PluginFactory;

import org.eclipse.swt.graphics.Image;

public class AdaptorLabelProvider extends LabelProvider {

	public String getText(Object obj) {
			return obj.toString();
	}

	public Image getImage(Object obj) {
		if (obj instanceof ITreeNode) {
			ImageDescriptor imgDescriptor = null;

			if (obj instanceof FactoryLeaf || obj instanceof FactoryParent
					|| obj instanceof PluginFactory) {
				imgDescriptor = Activator
						.getImageDescriptor("icon/factory.jpg");
			} else if (obj instanceof AdaptorLeaf
					|| obj instanceof AdaptorParent
					|| obj instanceof PluginAdapter) {
				imgDescriptor = Activator
						.getImageDescriptor("icon/adaptor.jpg");
			} else if (obj instanceof NamespaceParent || obj instanceof MyContributor)
				imgDescriptor = Activator.getImageDescriptor("icon/plugin.jpg");
			else 
				imgDescriptor = Activator.getImageDescriptor("icon/something.jpg");
			return imgDescriptor.createImage();
		}
		return null;
	}

}
